-
Notifications
You must be signed in to change notification settings - Fork 208
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
O3-1242 App crashes on logout #423
Conversation
devMiddleware: { | ||
writeToDisk: true, | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unrelated: this makes it so that yarn run:shell
plays nicer with yarn serve
ing the apps.
Noted with thanks! 😊 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for cleaning this Brandon
packages/apps/esm-login-app/src/redirect-logout/redirect-logout.component.tsx
Outdated
Show resolved
Hide resolved
<BrowserRouter basename={window.spaBase}> | ||
<Route | ||
exact | ||
path="/login(/confirm)?" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just checking, I haven't seen this syntax from react-router-dom before... doesn't look like plain text and doesn't look like regex?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't write this, but it looks like regex to me. Parentheses for grouping and a question mark for "optional;" i.e. this will match /login
or /login/confirm
.
Requirements
For changes to apps
If applicable
Summary
This fixes the broken logout functionality. It also fixes a problem where clicking "Change location" from the user menu in the primary navigation bar would lead to an "An error has occurred. Please try reloading the page." page.
The general idea of the fix is to make it so that
useSession
uses Suspense, so that it always either throws or returns a valid session object—it can no longer returnnull
.There is a substantial bit of refactoring worked in. I changed
getCurrentUser
to use Unistore rather than RxJS for state management, mostly because I have a much better understanding of how Unistore works, and am confident that it will behave synchronously when I expect it to (the behavior of Observables is ambiguous in this regard).I did my best to document the hook's implementation, since its complexity is increased substantially.
Screenshots
Related Issue
https://issues.openmrs.org/browse/O3-1242
Other
Ideally, this should be tested by E2E tests. CC @jayasanka-sack .